package com.hjwoo.app.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hjwoo.app.R;
import com.hjwoo.app.been.QueryDistrictObject;

import java.util.LinkedList;

public class CellInfoMationAdapter extends BaseAdapter
{

    Context                         context;
    LinkedList<QueryDistrictObject> ls;
    ViewHolder                      holder;
    private LayoutInflater inflater = null;

    public CellInfoMationAdapter(Context context, LinkedList<QueryDistrictObject> ls)
    {
        super();
        this.context = context;
        this.ls = ls;
        inflater = LayoutInflater.from(context);
        // 创建bitmap
    }

    @Override
    public int getCount()
    {
        return ls.size();
    }

    @Override
    public Object getItem(int arg0)
    {
        return arg0;
    }

    @Override
    public long getItemId(int arg0)
    {
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        // 定义一个视图容器
        holder = null;
        if (convertView == null)
        {
            // 获取ViewHolder对象
            holder = new ViewHolder();
            // 导入布局并赋值给convertview
            convertView = inflater.inflate(R.layout.item_cellinfomation_lv, null);
            holder.item_cell_tv = (TextView) convertView
                .findViewById(R.id.item_cell_tv);
            convertView.setTag(holder);
        }
        else
        {
            // 取出holder
            holder = (ViewHolder) convertView.getTag();
        }
        holder.item_cell_tv.setText(ls.get(position).getResidentialareaName());

        return convertView;
    }

    /**
     * 视图容器类
     *
     * @author kz
     */
    public static class ViewHolder
    {
        public TextView item_cell_tv;
    }

}
